$(function() {
    /*1.********动态获取html根字体************/
    setFontSize(720);

    /*2.********显隐积分规则************/
    show_rule();

    var token = localStorage.phone;
    $.ajax({
        url: "https://newapp.icandrive.cn/api/scoredetail.php",
        data: {
            token: token
        },
        dataType: 'json',
        type: 'post',
        success: function(data) {
            console.log(data);
          if(data.status == 200) {
              $(data.list).each(function() {
                /*  var cont = `<div class="int_list"><div class="left_word"><p class="type_font">'+this.type+'</p><p class="time_font">'+this.date+'</p></div><div class="right_word"><span class="num_font">'+this.score+'</span></div></div>`;*/



                  $('.img_box img').prop('src', this.photo);
                  $('#name').html(this.user_name);
                      $('#score span').html(this.myscore);

                  $('.integral_details').append('<div class="int_list"><div class="left_word"><p class="type_font">'+this.type+'</p><p class="time_font">'+this.date+'</p></div><div class="right_word"><span class="num_font">+'+this.score+'</span></div></div>');

              })
          }
          if(data.status == 250) {
              layer.msg("请重新登录");
              setInterval(function() {
                  window.location.href = "../login/log_in.html";
              }, 3000);
          }
          if(data.status == 300) {
          	 $('#score span').html("0");
              layer.msg("暂无积分，请努力");
          }
          if(data.status == 400) {
              layer.msg('系统繁忙');
              return false;
          }
        },
        error: function() {
            layer.msg('系统繁忙');
        }
    });
});

/*2.********显隐积分规则************/
function show_rule() {
    $("#integral_rule").click(function() {
        $(".rule").css({
            "display": "block"
        });
        $.ajax({
            url: "https://newapp.icandrive.cn/api/score_rule.php",
            data: {

            },
            dataType: 'json',
            type: 'post',
            success: function(data) {
                console.log(data);
                if(data.status == 200) {
                    $(data.list).each(function() {
                         var cont ='<tr><td>'+this.type+'</td><td>'+this.integral+'</td></tr>';
                  $('.rule table tbody').append(cont);
                    })
                }
            }
        });
    });
    $(".rule").click(function() {
        $(".rule tbody").html("");
        $(this).css({
            "display": "none"
        });
    });
}



/*监听手机返回按键*/
return_keybord();
